#ifndef SEVENCARDSTUDSQL_H
#define SEVENCARDSTUDSQL_H

#include "ProgSQL.h"
#include "SevenCardSavedGame.h"
#include "GameDBInterface.h"

class VPConnection;
class VPHand;


//************************************************************************************************
// kharmon.  03-22-06.  #10515.  7 Stud Poker
//
// This class implements all of the database related logic specific to the new 7 stud poker game.  
//
//************************************************************************************************
class SevenCardStudSQL : public GameDBInterface
{
public:

    SevenCardStudSQL(VPConnection *pConn, ProgressiveTrackSQL *pTracker, Info *pInfo);

    ~SevenCardStudSQL();
    

    // called to create a new seven card stud game and all related database entries.
	int32	trackNewGame(SevenCardSavedGame* saved, int32 *balance);

    // called to update the database with 2nd and 3rd bets (which are optional).
    int32   trackNextBet(int32 nStep, int32 nBet, int32 *pnBalance);

    // called when the user has made their LAST bet and the first part of the game is over.
    // The player may or may not have a "double up" phase still to complete.
    int32   trackShowAll(int32 nStep, int32 nFinalBet, int32 nPayout, int32 nSideBetPayout, 
                         VPHand *pDealt, uint8 aucBestCards[], int32 nPayType, 
                         int32 nSideBetPayType, uint8 ucDUActive, int32 *pnBalance);

    // called when the player has answered "No" to the double up question.
    bool8   trackDoubleUpDeny(int32 nPayout, int32 nSideBetPayout, int32 *pnBalance);

    // called when the player has answered "Yes" to the double up question
	bool8	trackDoubleUpDeal(int32 nRound, ShueSave*, int32* balance);

    // called when the player has selected either big or small.  If the player selected wrong, this
    // call completes the game.
	bool8	trackDoubleUpSelect(int32 nRound, VPHand *pDealt, uint8 ucChoice, 
                                uint8 ucWinResult, int32 nPayout, int32* pnBalance);


    // called to check for a saved game, and to load it if a saved game is found.
    bool8   processSavedGame(VPGameBase **ppGame, int32* err);


    // called to get the configuration settings for this game.
    virtual int32 getOptions(VPokerOpts*, uint8 machId, int32 creditValue);

    // called to get the compfactor for this game.
    virtual int32 getPlayerLimits(const PID&, int32 gameId, uint8 machId, int32* compFactor);



private:

    int32 createGame(SevenCardSavedGame*, int32 *pnBalance, int32* pnComp);

    int32 nextBet(int32 nStep, int32 nBet, int32 *pnBalance);

    int32 showAll(int32 nStep, int32 nFinalBet, int32 nPayout, int32 nSideBetPayout, 
                  VPHand *pDealt, uint8 aucBestCards[], int32 nPayType, 
                  int32 nSideBetPayType, uint8 ucDUActive, int32 *pnBalance);


    int32 hasSavedGame(SevenCardSavedGame* pDest, bool8* pbExists);

    int32 doubleUpDeny(int32 payout,  int32 nSideBetPayout, int32* balance, int32* comp);

    int32 doubleUpDeal(int32 nRound, ShueSave* pShueSave, int32* pnBalance, int32* pnComp);

    int32 doubleUpSelect(int32 nRound, VPHand *pDealt, uint8 ucChoice, uint8 ucWinResult, 
                         int32 nPayout, int32* pnBalance, int32* pnComp);

    VPConnection           *m_pConn;    // the connection to the client
    ProgressiveTrackSQL    *m_pTracker; // this has the real connection to the database...we don't own that, we just use it.
    Info                   *m_pInfo;    // misc. info about the current player session.

};





#endif